package com.sgdh.netty.constant;


public class KeyOperation implements IKeyOperation {
	private String message;
	private ClientNetty netty;

	public KeyOperation(ClientNetty netty) {
		message = new String();
		this.netty = netty;
	}

	@Override
	public void keyDown(int keycode) {
		String commond = String.format("%20s", "keyDown");
		String panelId= String.format("%20s", netty.getPanelId());
		String keyCode = String.format("%10d", keycode);
		message = commond+panelId+keyCode;
		netty.getChannel().writeAndFlush(message + '\n');
	}

	@Override
	public void keyUp(int keycode) {
		String command = String.format("%20s", "keyUp");
		String panelId= String.format("%20s", netty.getPanelId());
		String keyCode = String.format("%10d", keycode);
		message = command + panelId+keyCode;
		netty.getChannel().writeAndFlush(message + '\n');
	}

	@Override
	public void keyType(int keycode) {
		String command = String.format("%20s", "keyType");
		String panelId= String.format("%20s", netty.getPanelId());
		String keyCode = String.format("%10d", keycode);
		message = command + keyCode;
		netty.getChannel().writeAndFlush(message + '\n');
	}

}
